<?php
$appid='wx8af18d0fcf5dec93';
$appsercert='06103c6e8cb6c03de2ffaa40c1619710';
$tmp='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s';
$url=sprintf($tmp,$appid,$appsercert);
$ret=http_curl($url);//获取access_token
$ret=json_decode($ret);
$access_token=$ret->access_token;
$ip_url='https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token='.$access_token;
$ip_ret=http_curl($ip_url);
var_dump($ip_ret);exit;
function http_curl($url,$data='')
{
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    if (!empty($data)) {
        curl_setopt($ch,CURLOPT_POST,1);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output=curl_exec($ch);
    curl_close($ch);
    return $output;
}

